package com.cloudfast.platform.org.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import com.cloudfast.entity.BaseEntity;
import com.cloudfast.repository.annotation.DeleteField;
import com.cloudfast.repository.annotation.SelfGradeCode;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

/**
 * @author liuyw
 * @描述:
 * @date 2020年4月30日
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "sys_org")
@Getter
@Setter
public class Org extends BaseEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ApiModelProperty(value = "部门类型", required = true)
    private String orgType;

    @ApiModelProperty(value = "机构名称", required = true)
    private String orgName;
    @ApiModelProperty(value = "机构编码,唯一", required = true)
    private String orgCode;

    /**
     * 区域编码
     */
    @ApiModelProperty(value = "行政区域编码", required = true)
    private String regionCode;
    @ApiModelProperty(value = "上级机构", required = true)
    private Long parentId;

    @SelfGradeCode(fileEntity = "gradeCode")
    @Column(name = "grade_code", columnDefinition = " varchar(2550) DEFAULT NULL COMMENT '级联编码'")
    @ApiModelProperty(value = "级联编码", required = true)
    private String gradeCode;

    @ApiModelProperty(value = "创建时间", required = false)
    private Date createTime;

    /**
     * 是否不可见;顶级
     **/
    @ApiModelProperty(value = "是否是顶级机构", required = false)
    private String isAdmin = "0";

    /**
     * 删除的状态
     */
    @DeleteField
    @ApiModelProperty(value = "删除字体:默认0", required = false)
    private String delFlag = "0";

    public Org(Long id, String orgName) {
        this.id = id;
        this.orgName = orgName;
    }

    /**
     * @param orgName  部门名称
     * @param orgCode  部门编码
     * @param parentId 父类id
     */
    public Org(String orgName, String orgCode, Long parentId) {
        this.orgName = orgName;
        this.orgCode = orgCode;
        this.parentId = parentId;
    }

    public Org() {

    }

}
